package com.ruixi.spring.transaction.mapper;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;

@Repository
public class AccountMapperImpl implements AccountMapper{

    @Resource
    private JdbcTemplate jdbcTemplate;


    //加钱
    @Override
    public void addMoney() {
        String sql = "UPDATE account SET money = money + ? WHERE name = ?";
        this.jdbcTemplate.update(sql,100,"Mary");
    }

    //减钱
    @Override
    public void descMoney() {
        String sql = "UPDATE account SET money = money - ? WHERE name = ?";
        this.jdbcTemplate.update(sql,100,"Lucy");
    }
}
